using System.Linq;
using Magiq.Sql.Tests.TestModel;
using Magiq.Tests;
using NUnit.Framework;

namespace Magiq.Sql.Tests {
    [TestFixture]
    public class MagiqToSqlUpdatesTest : BaseMagiqProviderUpdatesTest<LinqToSqlTestClass1, LinqToSqlTestClass1Inheritor> {
        protected override IMagiqTestConfigurator GetConfigurator() {
            return MagiqToSqlTestConfigurator.Current;
        }

        [Test]
        [Ignore]
        public void ShouldUpdateChainedReferencesWithSeveralSetsThatInvalidatesTheWhereClauseWithCircularDependencies() {
            Magiq.Clear().Register(new MagiqToSql
                                       {
                                           DependentTablesUpdateStrategy = new TableVariableDependentUpdateStrategy()
                                       });

            TestUpdate(TestClass1s,
                       x => x.StringProperty == "sarasa" && x.Reference.StringProperty == "lolo",
                       s => s.Set(x => x.StringProperty, "lelelele")
                                .Set(x => x.Reference.StringProperty, "lala"),
                       items => items.Select(x => x.Reference).Distinct().Count() + items.Count());
        }
    }
}